/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function (initialState: any) {
  if (!!initialState) {
    const { menuData = [] } = initialState;
    return {
      canAdmin: (route: any) => {
        let a = false;
        if (!!menuData && menuData.length > 0) {
          for (let i = 0; i < menuData.length; i++) {
            if (route.path.includes(menuData[i].path)) {
              a = true;
            }
          }
          return a;
        }
      },
      redirect: true,
    };
  }
}
